package com.itheima.controller;

import com.itheima.entity.Result;
import com.itheima.resource.MessageConstant;
import com.itheima.service.ReportService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/report")
public class ReportController {

    @Reference
    private ReportService reportService;


    /**
     * 获取会员统计
     * @return
     */
    @RequestMapping("/getMemberReport.do")
    public Result getMemberReportLast12Month(){
        try {
            Map map=reportService.getMemberReportLast12Month();
            return new Result(true, MessageConstant.GET_MEMBER_NUMBER_REPORT_SUCCESS,map);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.GET_MEMBER_NUMBER_REPORT_FAIL);
        }

    }

    /**
     * 获取套餐统计
     * @return
     */
    @RequestMapping("/getSetmealReport.do")
    public Result getSetmealReport(){
        try {
            Map map=reportService.getSetmealReport();
            return new Result(true, MessageConstant.GET_SETMEAL_COUNT_REPORT_SUCCESS,map);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.GET_SETMEAL_COUNT_REPORT_FAIL);
        }

    }

    /**
     * 获取运营报表
     * @return
     */
    @RequestMapping("/getBusinessReport.do")
    public Result getBusinessReport() {
        try {
            Map map = reportService.getBusinessReport();
            return new Result(true, MessageConstant.GET_BUSINESS_REPORT_SUCCESS, map);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.GET_BUSINESS_REPORT_FAIL);
        }

    }

    /**
     * 导出运营报表
     * @return
     */
    @RequestMapping("/exportBusinessReport.do")
    public Result exportBusinessReport () {


        return null;
    }

}
